![]() |
ALMaSS
1.0
The Animal, Landscape and Man Simulation System
|
The class describing both local and seasonal goose memories and cognition. More...
#include <GooseMemoryMap.h>
Public Member Functions | |
GooseMemoryMap (Goose_Base *a_owner) | |
Constructor. More... | |
~GooseMemoryMap () | |
Destructor. More... | |
void | MemAdd (GooseMemoryLocation a_gml) |
Add a new memory location. More... | |
bool | MemDel (int a_polyid) |
Delete a memory location. More... | |
bool | ChangeAddFoodRes (int a_polyid, double a_foodres) |
Add to food at a memory location. More... | |
bool | ChangeAddThreat (int a_polyid, double a_threat) |
Add to threat at a memory location. More... | |
bool | ChangeMultFoodRes (int a_polyid, double a_foodres) |
Multiply food at a memory location. More... | |
bool | ChangeSetFoodRes (int a_polyid, double a_grain, double a_maize, double a_grazing) |
Set food at a memory location. More... | |
bool | ChangeMultThreat (int a_polyid, double a_threat) |
Multiply threat at a memory location. More... | |
double | GetFoodRes (int a_polyid) |
Get the food resource at location. More... | |
double | GetThreat (int a_polyid) |
Get the threat level at location. More... | |
GooseMemoryLocation | GetBestFeedingScore () |
Find the current best feeding location. More... | |
double | CalcScore (int a_dist, double a_foodresource, double a_threat) |
Inline function to calulate overall score for a distance, resource and threat. More... | |
bool | IsKnownArea (int a_polyid) |
Check if this location is known. More... | |
void | DecayAllMemory () |
Decay all memory. More... | |
double | GetTotalThreats (void) |
Get total of threat currently remembered. More... | |
void | ClearAllMemory (void) |
Remove all memory. More... | |
Protected Member Functions | |
void | GooseMemoryError (std::string a_str, int a_value) |
Error message functionality. More... | |
Protected Attributes | |
Goose_Base * | m_myOwner |
pointer to the owner More... | |
double | m_threatdecayrate |
The decay rate per day for threats. More... | |
int | m_expectedforagingtime |
the time in minutes a goose expects to be able to forage when evaluating cost benefit of flying to a location. More... | |
std::vector< GooseMemoryLocation > | m_memorylocations |
The list of memory locations. More... | |
The class describing both local and seasonal goose memories and cognition.
GooseMemoryMap::GooseMemoryMap | ( | Goose_Base * | a_owner | ) |
Constructor.
References cfg_goose_mem_expectedforagingtime, cfg_goose_mem_minmemoryvalue, cfg_goose_mem_threatdecayrate, GooseMemoryLocation::m_infinitememorystop, CfgInt::value(), and CfgFloat::value().
|
inline |
Destructor.
References m_memorylocations.
double GooseMemoryMap::CalcScore | ( | int | a_dist, |
double | a_foodresource, | ||
double | a_threat | ||
) |
Inline function to calulate overall score for a distance, resource and threat.
[in] | a_dist | The distance to the location |
[in] | a_foodresource | The foodresource at the location |
[in] | a_threat | A measure of the strength of threat memory. |
Referenced by Goose_Base::EvaluateForageToHopLoc(), Goose_Base::On_Bang(), and Goose_Base::st_ChooseForageLocation().
bool GooseMemoryMap::ChangeAddFoodRes | ( | int | a_polyid, |
double | a_foodres | ||
) |
Add to food at a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
a_foodres | [in] A measure of the strength of food resource memory. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find one bigger and add the food resource to be added
bool GooseMemoryMap::ChangeAddThreat | ( | int | a_polyid, |
double | a_threat | ||
) |
Add to threat at a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
a_threat | [in] A measure of the strength of threat memory. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find one bigger and add the threat to be added
Referenced by Goose_Base::On_Bang().
bool GooseMemoryMap::ChangeMultFoodRes | ( | int | a_polyid, |
double | a_foodres | ||
) |
Multiply food at a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
a_foodres | [in] A measure of the strength of food resource memory. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find one bigger and multiply by the value passed
bool GooseMemoryMap::ChangeMultThreat | ( | int | a_polyid, |
double | a_threat | ||
) |
Multiply threat at a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
a_threat | [in] The memory of a threat at this location |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find one bigger and multiply by the value passed
bool GooseMemoryMap::ChangeSetFoodRes | ( | int | a_polyid, |
double | a_grain, | ||
double | a_maize, | ||
double | a_grazing | ||
) |
Set food at a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
a_grain | [in] The grain food resource. |
a_maize | [in] The maize food resource. |
a_grazing | [in] The grazing food resource. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find our polygon.
References ALMaSS_MathFuncs::CalcDistPythagorasApprox(), g_AlmassMathFuncs, APoint::m_x, and APoint::m_y.
Referenced by Goose_Base::st_ChooseForageLocation(), and Goose_Base::st_Forage().
void GooseMemoryMap::ClearAllMemory | ( | void | ) |
Remove all memory.
void GooseMemoryMap::DecayAllMemory | ( | void | ) |
Decay all memory.
1 - Loop through all locations 2 - Decay the memory 3 - Update the memory score 4 - Remove any memories that are old
References ALMaSS_MathFuncs::CalcDistPythagorasApprox(), g_AlmassMathFuncs, and IsMarkedToDelete().
Referenced by Goose_Base::StartDay().
GooseMemoryLocation GooseMemoryMap::GetBestFeedingScore | ( | ) |
Find the current best feeding location.
0 - If there are no memories return an impossible score to trigger explore 1 - Loop through all locations. 2 - Keep track of the best score. 3 - We need a way out if nothing is at all suitable, so if score is too small return a dummy location with a big negative score. 4 - Return the best scoring location if we have one.
References GooseMemoryLocation::m_score.
Referenced by Goose_Base::st_ChooseForageLocation().
double GooseMemoryMap::GetFoodRes | ( | int | a_polyid | ) |
Get the food resource at location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list.
double GooseMemoryMap::GetThreat | ( | int | a_polyid | ) |
Get the threat level at location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list.
double GooseMemoryMap::GetTotalThreats | ( | void | ) |
Get total of threat currently remembered.
1 - Loop through all locations.
2 - Sum the threats and return this.
|
protected |
Error message functionality.
[in] | a_str | A string to send as output |
[in] | a_value | A value to send as output |
Opens a file called GooseMemoryMapError.txt and prints an error message before dumping the contents of the current memory. The program then closes.
bool GooseMemoryMap::IsKnownArea | ( | int | a_polyid | ) |
Check if this location is known.
a_polyid | [in] A unique polygon reference to a goose memory location. |
Loop through all locations and see if we have this polygon
If we have it, return true, otherwise return false.
Referenced by Goose_Base::st_ChooseForageLocation().
void GooseMemoryMap::MemAdd | ( | GooseMemoryLocation | a_gml | ) |
Add a new memory location.
a_gml | [in] A goose memory location to add to the memory list. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find one bigger and insert before it.
However, perhaps we have been here before, so just in case make a test and quitely update the memory if we find this polygon id in the list.
If no polygon ids are bigger or equal to ours then we need to add ours to the end of the list.
References GooseMemoryLocation::m_foodresource, GooseMemoryLocation::m_grain, GooseMemoryLocation::m_grazing, GooseMemoryLocation::m_maize, and GooseMemoryLocation::m_polygonid.
Referenced by Goose_Base::EvaluateForageToHopLoc(), Goose_Base::On_Bang(), and Goose_Base::st_ChooseForageLocation().
bool GooseMemoryMap::MemDel | ( | int | a_polyid | ) |
Delete a memory location.
a_polyid | [in] A unique polygon reference to a goose memory location. |
Here we make use of the fact that there should only be one of each entry, so no need to read the whole list, just stop when we find the right one and remove it
Referenced by Goose_Base::st_Forage().
|
protected |
the time in minutes a goose expects to be able to forage when evaluating cost benefit of flying to a location.
|
protected |
The list of memory locations.
Referenced by ~GooseMemoryMap().
|
protected |
pointer to the owner
|
protected |
The decay rate per day for threats.